package com.example.springboot011problemdetail.Exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ProblemDetail;
import org.springframework.web.ErrorResponseException;

import java.net.URI;

/**
 * @description: TODO
 * @author: uu
 * @data: 2023/7/8 下午 03:35
 * @version: v1.0
 */
public class IsbnNotFoundException extends ErrorResponseException {

    public IsbnNotFoundException(HttpStatus status, String detail) {
        super(status,createProblemDetail(status,detail),null);
    }
    private static ProblemDetail createProblemDetail(HttpStatus status, String detail)
    {
        ProblemDetail problemDetail = ProblemDetail.forStatus(status);
        problemDetail.setType(URI.create("/api/probs/not-found"));
        problemDetail.setTitle("图书异常");
        problemDetail.setDetail(detail);
//增加自定义字段
        problemDetail.setProperty("严重程度", "低");
        problemDetail.setProperty("客服邮箱", "sevice@bjpowernode.com");
        return problemDetail;
    }
}
